package com.ld.wms.business.locker.controller;


import com.ld.wms.business.locker.service.LockerGridService;
import com.ld.wms.business.locker.vo.req.LockerGridReqVo;
import com.ld.wms.business.locker.vo.req.LockerReqVo;
import com.ld.wms.business.locker.vo.resp.LockerGridRespVo;
import com.ld.wms.common.ResultResponse;
import com.ld.wms.common.vo.PrimaryKeyReqVo;
import com.ld.wms.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 智能柜每个格子的信息 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2025-03-28
 */
@Slf4j
@Tag(name = "智能柜体抽屉相关接口")
@RestController
public class LockerGridController {

    @Autowired
    private LockerGridService lockerGridService;

    @PostMapping("/api/wms/lockerGrid/configLockerGrid")
    @Operation(summary = "配置柜体格子")
    public ResultResponse<ResultResponseEnum> configLockerGrid(
            @RequestBody LockerGridReqVo reqVo
    ) {
        lockerGridService.configLockerGrid(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/wms/lockerGrid/resetLockerGrid")
    @Operation(summary = "重置柜体格子")
    public ResultResponse<ResultResponseEnum> resetLockerGrid(
            @RequestBody PrimaryKeyReqVo reqVo
    ) {
        lockerGridService.resetLockerGrid(reqVo.getId());
        return ResultResponse.success();
    }

    @GetMapping("/api/wms/lockerGrid/getDetails")
    @Operation(summary = "柜体格子详情")
    public ResultResponse<LockerGridRespVo> getDetails(
            @RequestParam Long id
    ) {
        LockerGridRespVo lockerGridRespVo = lockerGridService.getDetails(id);
        return ResultResponse.success(lockerGridRespVo);
    }
}

